package org.grow.leavejpa.controller;


import org.grow.leavejpa.entity.Leave;
import org.grow.leavejpa.entity.UserInfo;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * @Author: xwg
 * @CreateDate: 21-6-7
 */
@RestController
public class SomeController {

    @GetMapping
    public String testMvc(){
        return LocalDateTime.now().toString();
    }

    @PostMapping("/applyLeave")
    public Boolean applyLeave(@RequestBody Leave leave){
        UserInfo principal = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        System.out.println(principal);
        System.out.println(leave);
        return true;
    }



}
